package br.ufrn.dimap.ase.squid.metrics.views.tree;

import java.net.URL;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;

import br.ufrn.dimap.ase.squid.metrics.views.tree.model.ITreeable;

public class MetricsLabelProvider extends LabelProvider {
	private static final Image FOLDER = getImage("sample.gif");
	private static final Image FILE = getImage("file.gif");

	@Override
	public String getText(Object element) {
		if(element != null)
			return element.toString();
		
		return null;
	}

	@Override
	public Image getImage(Object element) {
//		if(element instanceof ITreeable)
//			return FOLDER;
		return null;
	}

	// Helper Method to load the images
	private static Image getImage(String file) {
		Bundle bundle = FrameworkUtil.getBundle(MetricsLabelProvider.class);
	    URL url = FileLocator.find(bundle, new Path("icons/" + file), null);
	    ImageDescriptor image = ImageDescriptor.createFromURL(url);
	    return image.createImage();
	}
}
